//package com.uwo.house.advice;
//
//import com.uwo.house.config.AccessTokenException;
//import org.apache.log4j.Logger;
//import org.apache.shiro.authc.UnknownAccountException;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//import java.util.HashMap;
//import java.util.Map;
//
///**
//* 全局异常处理
//* Created by yanhao on 2017/6/5.
//*/
//@ControllerAdvice
//public class GlobalExceptionHandler {
//
////  private final Logger logger = Logger.getLogger(GlobalExceptionHandler.class);
//
//  // Exception处理
//  @ExceptionHandler(Exception.class)
//  @ResponseBody
//  public Object handle(Exception e) {
//      logger.warn("Exception: " + e.getMessage());
//      // 返回内容
//      Map<String, Object> result = new HashMap<String, Object>();
//      result.put("message", e.getMessage());
//      // 请求参数为空的异常
//      if(e instanceof AccessTokenException) {
//          AccessTokenException accessTokenException = (AccessTokenException)e;
//          result.put("code", accessTokenException.getCode());
//      }else if(e instanceof UnknownAccountException) {
//          result.put("code", Code.UNKNOW_ACCOUNT.getCode());
//      }
//      // 业务失败返回
//      return result;
//  }
//}